<%@page import="com.wowangz.cms.common.utils.DictTypeConstant"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/pageHead.jsp"%>
<c:set value="<%=SysConstant.CommonApproveStatus.SAVED %>" var="state"></c:set>
<c:set value="<%=SysConstant.CommonApproveStatus.REFUSED %>" var="refuse"></c:set>

<link rel="stylesheet" type="text/css" href="${systemctx}/resources/css/table.css">
<link rel="stylesheet" type="text/css" href="${systemctx}/resources/ztree/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="${systemctx }/resources/ztree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="${systemctx }/resources/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript">
	var setting = {
		data: {
			key: {
				title:"t"
			},
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};
	
	var zNodes = ${treeJson};
	
	function onClick(event, treeId, treeNode) {
		/* alert(treeNode.id) */
		if(treeNode.id == '${column.id}'){
			alert('不能选择自己的节点');
			return ;
		}
		$("#parentcolumnname").val(treeNode.name);
		$("#parentcolumn").val(treeNode.id);
		$(".treeColumn").css('display','none');
	}		
	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});
	$(document).ready(function() {
		$("#display").selectutil({
			optModel : <%=SysConstant.Display.getMode1JSONString(true, false)%>,
			optDefault :'${column.display}'
		});
		$("#parentcolumnname").click(function(){
			$("#columnTree").css('display','block').css('left',$(this).offset().left);
		});
		
		$(".treeColumn").mouseleave(function(){
			$(".treeColumn").css('display','none');
		});
		
		$("#butReturn").click(function(){
			parent.document.location.reload();
			$.fn.closeIssWindow();
		});
	});
	function save(){
		var exp = $('#form1').validationEngine('validate');
		var parentcolumnname = $("#parentcolumnname").val();
		if(parentcolumnname==''){
			$('#parentcolumn').val('');
		}
		if(exp==true){
			// 显示进度条
			showSending();
			$.ajax({
				type: 'POST',
			    url: '${systemctx}/topic/colunm/updateColumn.json',
			    data: $("#form1").serialize(),
			    dataType: 'json',
			    success: function(data) {
			    	//关闭执行...
					closeSending();
			    	if(data.messagetype == 1){
			    		alert(data.message)
			    		parent.document.location.reload();
					    $.fn.closeIssWindow();
			    	}else {
			    		alert(data.message)
			    		return;
			    	}
			    }
			});
		}
	}
</script>
<form name="form1" id="form1" action="" method="post">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.contentmanagement.title")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "topic.column.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "topic.column.module.edit.title") %>
		</div>
		<div class="pageBody">
			<table id="editTable" class="formTableCommStyle">
				<tr>
					<td class="TableTd1">
						<i>*</i>
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.colunmcode") %>
					</td>
					<td class="TableTd2">
						<input value="${column.id}" name="id" id="id" type="hidden">
						<input value="${columncode}" name="columncode" id="columncode" type="hidden">
						<input type="text" value="${column.columncode}" disabled="disabled" size="22" class="validate[required,maxSize[20]]" />
					</td>
					<td class="TableTd3">
						<i>*</i>
						<!-- 栏目名称 -->
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.columnname") %>
					</td>
					<td class="TableTd4">
						<input type="text" id="columnname" value="${column.columnname}" name="columnname" maxlength="50" size="50" class="validate[required,maxSize[50]]" />
					</td>
				</tr>
				<tr>
					<td class="TableTd1">
						<i>&nbsp;</i>
						<!-- 上级栏目 -->
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.parentcolumnname") %>
					</td>
					<td class="TableTd2">
						<input type="hidden" name="parentcolumn" value="${parentcolumn}" id="parentcolumn">
						<input type="text" value="${parentcolumnname}" name="parentcolumnname" id="parentcolumnname">
						<div id="columnTree" class="treeColumn">
							<div class="zTreeDemoBackground left">
								<ul id="treeDemo" class="ztree"></ul>
							</div>
						</div>
					</td>
					
					<td class="TableTd3">
						<i>*</i>
						<!-- 是否显示 -->
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.display") %>
					</td>
					<td class="TableTd4">
						<select name="display" id="display" class="validate[required]"></select>
					</td>
				</tr>
			</table>			
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butSave" onclick="save()" name="butSave"  value='<%=MessageResourcesUtils.getMessage(request, "common.button.update") %>' />
			<input type="button" class="btn btn-default" id="butReturn" name="butReturn" value='<%=MessageResourcesUtils.getMessage(request, "common.button.back") %>' />
		</div>
	</div>
</form>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>